/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package cn.ekuma.epos.datalogic.define.dao;

import cn.ekuma.data.dao.BaseDAO;
import cn.ekuma.epos.db.table.I_Floor;
import com.openbravo.data.basic.BasicException;
import com.openbravo.data.loader.DataRead;
import com.openbravo.data.loader.DataWrite;
import com.openbravo.data.loader.Datas;
import com.openbravo.data.loader.I_Session;
import com.openbravo.data.loader.ImageUtils;
import com.openbravo.data.loader.Session;
import com.openbravo.data.loader.TableDefinition;
import com.openbravo.data.model.Field;
import com.openbravo.format.Formats;
import com.openbravo.pos.bean.FloorExt;

/**
 *
 * @author Administrator
 */
public class FloorExtDAO extends BaseDAO<FloorExt>{

    public FloorExtDAO(I_Session s) {
        super(s);
    }
    
    @Override
    public TableDefinition getTable() {
        return new TableDefinition(s,
                  "FLOORS",
                  new Field[]{
                     new Field(I_Floor.ID,Datas.STRING, Formats.STRING),
                     new Field(I_Floor.NAME,Datas.STRING, Formats.STRING),
                     new Field(I_Floor.IMAGE,Datas.IMAGE, Formats.NULL)
                  },
                  new int[]{0}
                );
    }

    @Override
    public void writeInsertValues(DataWrite dp, FloorExt obj) throws BasicException {
          dp.setString(1, obj.getID());
          dp.setString(2, obj.getName());
          dp.setBytes(3, obj.getImage());
    }

    public FloorExt readValues(DataRead dr,FloorExt floor) throws BasicException {
        if(floor==null)
        	floor=new FloorExt();
        floor.setID(dr.getString(1));
        floor.setName( dr.getString(2));
        floor.setImage(dr.getBytes(3));
        return floor;
    }

    @Override
    public Class getSuportClass() {
        return FloorExt.class;
    }

}
